package com.pbdatabase.core.query;

import com.pbdatabase.core.main.IndexProcessor;
import com.pbdatabase.core.main.ProtoProcessor;
import org.apache.log4j.Logger;

public class DefinitionQueryHandler {
	private static Logger _logger = Logger.getLogger(DefinitionQueryHandler.class);
	private ProtoProcessor protoProcessor;
	private IndexProcessor indexProcessor;

	public void create(String protoName, String protoDefinition, String indexField) {
		// Save proto
		ProtoProcessor.saveProto(protoName, protoDefinition);
		_logger.info("Creating table for protocol buffer: " + protoName);

		// Initialize index for new proto
		IndexProcessor indexProcessor = IndexProcessor.getInstance();
		indexProcessor.addIndexer(protoName);
		_logger.debug("Initializing index for this proto");
	}

	public void delete(String protoName) {
		_logger.info("Deleting table for protocol buffer: " + protoName);
		// Disabled right now
		// TODO: Delete proto
		// TODO: Delete related index
	}

	public void update(String protoName) {
		_logger.info("Updating table for protocol buffer: " + protoName);
		// Disabled right now
		// TODO: Change to allow updates
	}

}
